public class Example28 {
    public static void main(String[] args) {
        int[] arr = {4, 2, 6, 3, 9, 8};
        int max = getMax(arr);
        int min = getMin(arr);
        System.out.println("max=" + max);
        System.out.println("min=" + min);
    }

    static int getMax(int[] arr) {
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] > max) {
                ; //比较arr【x】的值是否大于max
                max = arr[i];
            }
        }
        return max;
    }
    static int getMin(int[] arr) {
        int min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] < min) {
                ; //比较arr【x】的值是否大于max
                min = arr[i];
            }
        }
        return min;
    }
}